package com.example.demo.service;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import com.example.demo.entity.MyUser;
import com.example.demo.repository.MyUserRepository;

@Service
public class MyUserService {
	
	@Resource
	private  MyUserRepository myUserRepository;
	@Resource
	private PasswordEncoder passwordEncoder;
	
	@Transactional
	public MyUser regist(MyUser myUser) {
		myUser.setPassword(passwordEncoder.encode(myUser.getPassword()));
		return myUserRepository.save(myUser);
		
	}
}
